package com.fms.dto;

import lombok.*;
import lombok.experimental.SuperBuilder;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

/**
 * <p>用于Controller接收Json转换为对象的类</p>
 */
@Component
@RequiredArgsConstructor
public class JsonRequest {

    public static abstract class AbstractRequest {
    }

    @Getter
    @Setter
    @SuperBuilder
    @AllArgsConstructor
    @NoArgsConstructor
    public static abstract class AbstractPageRequest {
        private Integer page;
        private Integer pageSize;
    }


    /**
     * 修改密码请求
     */
    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    public static class PasswordRequest extends AbstractRequest {
        private String oldPassword;
        private String newPassword;
    }

    /**
     * 任务创建请求
     */
    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    public static class AttendanceTaskRequest extends AbstractRequest {
        private List<Long> deptIds;
        private LocalTime startTime;
        private LocalTime inDeadline;
        private LocalTime outDeadline;
        private List<Integer> weekDays;
        private Double longitude;
        private Double latitude;
    }

    /**
     * 签到任务分页请求
     */
    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    public static class AttendanceTaskPageRequest extends AbstractPageRequest {
        private Long deptId;
        private Integer status;
    }

    /**
     * 签到请求
     */
    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    public static class AttendedOfAttendanceRequest extends AbstractRequest{
        private Long id;//具体签到任务id
        private LocalDateTime inDeadline;//签到时间
        private LocalDateTime startTime;//任务开始时间
        private LocalDateTime outDeadline;//签退时间
        private String imgUrl;//图片url
        private Double attendedLongitude;
        private Double attendedLatitude;//打卡经纬度
        private Double shouldLongitude;
        private Double shouldLatitude;//签到经纬度
        private Integer type;//签到类型，1：签到；2：补签；3：签退
    }


    /**
     * 获取签到分页请求
     */
    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    public static class AttendanceOfUserPageRequest extends AbstractPageRequest {
        private LocalTime startTime; //'开始时间'
        private LocalDate date; //'签到日期',
        private Integer status;  //'签到状态，1：已创建开启（未签到）-> 2：签到 -> 3：补签 -> 4:签退 -> 5:任务结束'
    }


    /**
     * 所有签到分页请求
     */
    @Setter
    @Getter
    @SuperBuilder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class AttendancePageRequest extends AbstractPageRequest {
        private LocalDate date; //'签到日期',
        private LocalTime startTime; //'开始时间'
        private Integer status;  //'签到状态，1：已创建开启（未签到）-> 2：签到 -> 3：补签 -> 4:签退 -> 5:任务结束'
        private String username; //'用户姓名'
        private Long deptId;//角色
    }

    /**
     * 统计签到情况
     */
    @Setter
    @Getter
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @ToString
    public static class AttendanceNumberRequest extends AbstractRequest {
        private String name;
        private Long deptId;
        private Integer maxHoliday;//最大请假天数
        private LocalDate startDate;//开始日期
        private Integer monthNumber;//统计月数
    }
}
